﻿using AntdUI;
using SqlSugar;

namespace WorkTool2.Classes.Data;

public class DbTableColumns : NotifyProperty
{
    private string _columnName;

    /// <summary>
    /// 字段名
    /// </summary>
    public string ColumnName
    {
        get => _columnName;
        set { _columnName = value; OnPropertyChanged(); }
    }

    private string _columnKey;

    /// <summary>
    /// 主键
    /// </summary>
    public string ColumnKey
    {
        get => _columnKey;
        set { _columnKey = value; OnPropertyChanged(); }
    }

    /// <summary>
    /// 字段名 + 主键
    /// </summary>
    [SugarColumn(IsIgnore = true)]
    public string ColumnNameAndKey
    {
        get
        {
            if (string.IsNullOrEmpty(_columnKey))
                return _columnName;
            else
                return $"{_columnName} ({_columnKey})";
        }
    }

    private string _columnType;

    /// <summary>
    /// 字段类型
    /// </summary>
    public string ColumnType
    {
        get => _columnType;
        set { _columnType = value; OnPropertyChanged(); }
    }

    private string _isNullable;

    /// <summary>
    /// 可为空
    /// </summary>
    public string IsNullable
    {
        get => _isNullable;
        set { _isNullable = value; OnPropertyChanged(); }
    }

    private string _columnComment;

    /// <summary>
    /// 字段描述
    /// </summary>
    public string ColumnComment
    {
        get => _columnComment;
        set { _columnComment = value; OnPropertyChanged(); }
    }

    private string _characterSetName;

    /// <summary>
    /// 编码
    /// </summary>
    public string CharacterSetName
    {
        get => _characterSetName;
        set { _characterSetName = value; OnPropertyChanged(); }
    }

    private string _extra;

    /// <summary>
    /// 其他
    /// </summary>
    public string Extra
    {
        get => _extra;
        set { _extra = value; OnPropertyChanged(); }
    }
}